package org.king.entity.vo;

import javafx.beans.property.*;
import lombok.Data;
import org.king.entity.Activity;

import java.time.LocalDateTime;

@Data
public class ActivityEntity implements Cloneable  {
    private int id = 0;
    private final StringProperty name = new SimpleStringProperty("");
    private final StringProperty description = new SimpleStringProperty("");
    private final ObjectProperty<LocalDateTime> beginTime = new SimpleObjectProperty<>(LocalDateTime.now());
    private final ObjectProperty<LocalDateTime> endTime = new SimpleObjectProperty<>(LocalDateTime.now());
    private final StringProperty address = new SimpleStringProperty("");
    private int creator = 0;


    // 构造方法
    public ActivityEntity(Activity activity) {
        this.id=activity.getActivity_id();
        this.name.set(activity.getName());
        this.description.set(activity.getActivity_describe());
        this.setBeginTime(activity.getBegin_time().toLocalDateTime());
        this.setEndTime(activity.getEnd_time().toLocalDateTime());
        this.address.set(activity.getAddress());
        this.setCreator(activity.getCreate_id());
    }
    public ActivityEntity(){
    }
    public String getName() {
        return name.get();
    }
    public void setName(String name) {this.name.set(name);}
    public StringProperty nameProperty() {
        return name;
    }

    public String getDescription() {
        return description.get();
    }
    public void setDescription(String description) {this.description.set(description);}
    public StringProperty descriptionProperty() {
        return description;
    }

    public LocalDateTime getBeginTime() {
        return beginTime.get();
    }
    public void setBeginTime(LocalDateTime beginTime) {this.beginTime.set(beginTime);}
    public ObjectProperty<LocalDateTime> beginTimeProperty() {
        return beginTime;
    }

    public LocalDateTime getEndTime() {
        return endTime.get();
    }
    public void setEndTime(LocalDateTime endTime) {this.endTime.set(endTime);}
    public ObjectProperty<LocalDateTime> endTimeProperty() {
        return endTime;
    }

    public String getAddress() {
        return address.get();
    }
    public void setAddress(String address) {this.address.set(address);}
    public StringProperty addressProperty() {
        return address;
    }

    @Override
    public ActivityEntity clone() {
        try {
            ActivityEntity clone = (ActivityEntity) super.clone();
            clone.address.set(address.get());
            clone.creator = creator;
            clone.description.set(description.get());
            clone.beginTime.set(beginTime.get());
            clone.endTime.set(endTime.get());
            clone.name.set(name.get());
            return clone;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}